<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateGoodsOrdersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('goods_orders', function (Blueprint $table) {
            $table->id();

            $table->string('order_num')->comment("订单号");
            $table->tinyInteger("order_type")->default(0)->comment("订单类型 0游客订单 1学校用户订单");
            $table->string('phone',25)->nullable()->comment("手机号");
            $table->unsignedInteger('users_id')->comment("用户id");
            $table->unsignedInteger('school_id')->comment("学校id");
            $table->double('total_price', 12, 2)->comment("支付金额");
            $table->tinyInteger("pay_type")->default(0)->comment("支付方式  注：暂时不用");

            $table->string('address')->comment("地址");
            $table->string('logistics')->comment("物流名称");
            $table->string('logistics_order')->comment("物流订单号");
            $table->unsignedInteger('address_id')->comment("邮寄地址");
            $table->text('message')->comment("购买者留言信息")->nullable();

            $table->tinyInteger("status")->default(0)->comment("待确认:待支付:2已付款:3已发货:4已收货:5已完成;6退款退货 7已取消");
            $table->dateTime('pay_time')->nullable()->comment("支付时间");
            $table->dateTime('consignment_time')->nullable()->comment("发货时间");
            $table->dateTime('end_time')->nullable()->comment("交易完成时间");
            $table->dateTime('close_time')->nullable()->comment("交易关闭时间");
            $table->string('contact_person')->comment("联系人");
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('goods_orders');
    }
}
